module Magic
  class ExceptionWrapper < Exception

    attr_accessor :original_exception

    def initialize message, exception = nil
      if exception
        self.original_exception = exception
        message += ' '+exception.message
      end
      super(message)
    end

    def backtrace
      if original_exception
        original_exception.backtrace
      else
        super()
      end
    end
  end
end